<?php
/**
 * Created by PhpStorm.
 * User: 84071
 * Date: 2018-10-04
 * Time: 11:57
 */
namespace app\api\controller;

use app\common\controller\Apibase;
use app\common\model\OrderMake as cxModel;

class OrderMake extends Apibase{

    public function get_make(){
        $res['code'] = '0';
        $getdata = request()->param();
        $getdata = datatrim($getdata);
        $cxmodel = new cxModel();
        $make = $cxmodel->where('id',$getdata['id'])->find()->toArray();
        $make['vipname'] = '等待分配老师';
        $make['vipphone'] = '等待分配老师';
        $make['maketime'] = date('Y-m-d H:i:s',$make['maketime']);
        if(!empty($make['vipuid'])){
            $userdata = model('UserData')->where('uid',$make['vipuid'])->find();
            $make['vipname'] = $userdata['uname'];
            $make['vipphone'] = $userdata['uphone'];
        }
        $make['arttitle'] = model('Article')->where('aid',$make['aid'])->value('title');
        $make['useraddress'] = model('UserAddress')->where('id',$make['resid'])->find()->toArray();
        if($make['status'] == '0'){
            if(!empty($make['foid'])){
                $playstatus = model('Order')->where('oid',$make['foid'])->value('playstatus');
                if($playstatus == '0'){
                    $make['btn'] = "<a class='button bg-green'>等待付款</a>";
                }else{
                    $make['btn'] = "<a class='button bg-green'>等待平台确认</a>";
                }
            }else{
                $make['btn'] = "<a class='button bg-green'>等待平台确认</a>";
            }
        }
        if($make['status'] == '1'){
            $make['btn'] = "<a class='button bg-green'>等待老师上门</a>";
        }
        if($make['status'] == '2'){
            $make['btn'] = "<a class='button'>课程结束</a>";
        }


        $res['code'] = '1';
        $res['msg'] = '查询成功';
        $res['cont'] = $make;
        return json($res);
    }
    //  调用课程表
    public function get_maketable(){
        $res['code'] = "0";
        $getdata = request()->param();
        if(empty($getdata['vip'])){
            $res['msg'] = "请选择要查询老师";
            return json($res);
        }
        $cxmodel = new cxModel();
        $list = $cxmodel->get_maketable($getdata);
        if($list != false){
            $res['code'] = "1";
            $res['msg'] = "查询成功";
            $res['list'] = $list;
        }
        return json($res);
    }


}